<template>
  <el-dialog
    title="违章信息"
    :close-on-click-modal="false"
    :visible.sync="visible">
    <el-form label-width="80px">
      <el-form-item label="车牌号">
        <el-input readonly v-model="dataForm.plateNumber"></el-input>
      </el-form-item>
      <el-form-item label="违章时间">
        <el-input readonly v-model="dataForm.violationTime"></el-input>
      </el-form-item>
      <el-form-item label="违章地点">
        <el-input readonly v-model="dataForm.violationAddress"></el-input>
      </el-form-item>
      <el-form-item label="违章类型">
        <el-input readonly v-model="dataForm.violationTypeName"></el-input>
      </el-form-item>
      <el-form-item label="被扣分数">
        <el-input readonly v-model="dataForm.score"></el-input>
      </el-form-item>
      <el-form-item label="说明">
        <el-input readonly v-model="dataForm.description"></el-input>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>

<script>
  export default {
    data () {
      return {
        visible: false,
        dataForm: {}
      }
    },
    methods: {
      getViolationInfo (violationId) {
        this.$http({
          url: this.$http.adornUrl(`/mvs/violation/${violationId}`),
          method: 'get'
        }).then(({data}) => {
          if (data && data.code === 0) {
            this.dataForm = data.violation
          } else {
            this.dataForm = []
          }
        })
      },
      init (id) {
        this.getViolationInfo(id)
        this.visible = true
      }
    }
  }
</script>
